package com.gpframework.module.process.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gpframework.common.utils.DateUtils;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.process.domain.GpProcessCosting;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @ClassName GpProcessCostingReq
 * @Author gpframework
 * @Date 2023-12-20
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class GpProcessCostingReq extends BaseReq {
    private static final long serialVersionUID = 1L;

         @ApiModelProperty("${column.columnComment}")
     private Long id;
     @ApiModelProperty("品牌id")
     private String brandId;
     @ApiModelProperty("品牌名称")
     private String brandName;
     @ApiModelProperty("缺货报库存申请表id")
     private Long productionApplicationId;
     @ApiModelProperty("排单表id")
     private Long processSchedulingId;
     @ApiModelProperty("到货单id")
     private Long processDeliveryNoteId;
     @ApiModelProperty("订单号")
     private String sn;
     @ApiModelProperty("批号")
     private String batchNo;
     @ApiModelProperty("成品品名")
     private String productName;
     @ApiModelProperty("成品颜色")
     private String productColor;
     @ApiModelProperty("成本")
     private BigDecimal cost;
     @ApiModelProperty("加工商ID")
     private Long processorId;
     @ApiModelProperty("加工商")
     private String processor;
     @ApiModelProperty("加工费")
     private BigDecimal processFee;
     @ApiModelProperty("排单表id")
     private String schedulingId;
     @ApiModelProperty("底布品名")
     private String backerName;
     @ApiModelProperty("底布颜色")
     private String backerColor;
     @ApiModelProperty("底布数量")
     private BigDecimal backerNum;
     @ApiModelProperty("底布价格表id")
     private Long backerPriceId;
     @ApiModelProperty("底布价格")
     private BigDecimal backerPrice;
     @ApiModelProperty("成品条数")
     private Integer quantity;
     @ApiModelProperty("打码规格/空码")
     private BigDecimal codingSpecificationsEmpty;
     @ApiModelProperty("打码规格/足码")
     private BigDecimal codingSpecificationsSufficient;
     @ApiModelProperty("大小条码数")
     private Integer sizeBar;
     @ApiModelProperty("成品入库总码数（空）")
     private Integer totalSizeEmpty;
     @ApiModelProperty("成品总码数（足）")
     private Integer totalSizeSufficient;
     @ApiModelProperty("损耗数量")
     private Integer lossQuantity;
     @ApiModelProperty("损耗率")
     private BigDecimal lossRate;
     @ApiModelProperty("备注")
     private String remarks;
     @ApiModelProperty("操作人id")
     private Long operatorId;
     @ApiModelProperty("操作人")
     private String operatorName;
     @ApiModelProperty("操作")
     private String operate;
     @ApiModelProperty("创建者")
     private String createBy;
     @ApiModelProperty("创建时间")
     private Date createTime;
     @ApiModelProperty("更新者")
     private String updateBy;
     @ApiModelProperty("更新时间")
     private Date updateTime;
     @ApiModelProperty("删除标记;0未删除。1已删除。")
     private Integer delStatus;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date searchDate;
    /** 操作人编号 */
    @ApiModelProperty("操作人编号")
    private String operatorNum;
    /**审批人名称 */
    @ApiModelProperty("审批人名称")
    private String examinName;
    @ApiModelProperty("查询条件（订单号/客户名）")
    private String searchName;

    /** 特征 */
    @ApiModelProperty("特征")
    private String characteristic;

    /**
    * @Description 生成查询wrapper
    * @Author greatplan@qq.com
    * @Date 2020-11-04 16:04
    * @Param [lqw]
    * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
    * @Return void
    */
    public void generatorQuery(QueryWrapper<GpProcessCosting> lqw,boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias+"del_status",0);
        }
        if (this.getId() != null){
        lqw.eq(alias+"id" ,this.getId());
        }
        if (StringUtils.isNotBlank(this.getBrandId())){
        lqw.eq(alias+"brand_id" ,this.getBrandId());
        }
        if (StringUtils.isNotBlank(this.getBrandName())){
            lqw.like(alias+"brand_name",this.getBrandName());
        }
        if (this.getProductionApplicationId() != null){
        lqw.eq(alias+"production_application_id" ,this.getProductionApplicationId());
        }
        if (this.getProcessSchedulingId() != null){
        lqw.eq(alias+"process_scheduling_id" ,this.getProcessSchedulingId());
        }
        if (this.getProcessDeliveryNoteId() != null){
        lqw.eq(alias+"process_delivery_note_id" ,this.getProcessDeliveryNoteId());
        }
        if (StringUtils.isNotBlank(this.getSn())){
        lqw.like(alias+"sn" ,this.getSn());
        }
        if (StringUtils.isNotBlank(this.getBatchNo())){
        lqw.like(alias+"batch_no" ,this.getBatchNo());
        }
        if (StringUtils.isNotBlank(this.getProductName())){
            lqw.like(alias+"product_name",this.getProductName());
        }
        if (StringUtils.isNotBlank(this.getProductColor())){
        lqw.like(alias+"product_color" ,this.getProductColor());
        }
        if (this.getCost() != null){
        lqw.eq(alias+"cost" ,this.getCost());
        }
        if (this.getProcessorId() != null){
        lqw.like(alias+"processor_id" ,this.getProcessorId());
        }
        if (StringUtils.isNotBlank(this.getProcessor())){
        lqw.eq(alias+"processor" ,this.getProcessor());
        }
        if (this.getProcessFee() != null){
        lqw.eq(alias+"process_fee" ,this.getProcessFee());
        }
        if (StringUtils.isNotBlank(this.getSchedulingId())){
        lqw.eq(alias+"scheduling_id" ,this.getSchedulingId());
        }
        if (StringUtils.isNotBlank(this.getBackerName())){
            lqw.like(alias+"backer_name",this.getBackerName());
        }
        if (StringUtils.isNotBlank(this.getBackerColor())){
        lqw.like(alias+"backer_color" ,this.getBackerColor());
        }
        if (this.getBackerNum() != null){
        lqw.eq(alias+"backer_num" ,this.getBackerNum());
        }
        if (this.getBackerPriceId() != null){
        lqw.eq(alias+"backer_price_id" ,this.getBackerPriceId());
        }
        if (this.getBackerPrice() != null){
        lqw.eq(alias+"backer_price" ,this.getBackerPrice());
        }
        if (this.getQuantity() != null){
        lqw.eq(alias+"quantity" ,this.getQuantity());
        }
        if (this.getCodingSpecificationsEmpty() !=null){
        lqw.eq(alias+"coding_specifications_empty" ,this.getCodingSpecificationsEmpty());
        }
        if (this.getCodingSpecificationsSufficient() !=null){
        lqw.eq(alias+"coding_specifications_sufficient" ,this.getCodingSpecificationsSufficient());
        }
        if (this.getSizeBar() != null){
        lqw.eq(alias+"size_bar" ,this.getSizeBar());
        }
        if (this.getTotalSizeEmpty() != null){
        lqw.eq(alias+"total_size_empty" ,this.getTotalSizeEmpty());
        }
        if (this.getTotalSizeSufficient() != null){
        lqw.eq(alias+"total_size_sufficient" ,this.getTotalSizeSufficient());
        }
        if (this.getLossQuantity() != null){
        lqw.eq(alias+"loss_quantity" ,this.getLossQuantity());
        }
        if (this.getLossRate() != null){
        lqw.eq(alias+"loss_rate" ,this.getLossRate());
        }
        if (StringUtils.isNotBlank(this.getRemarks())){
        lqw.eq(alias+"remarks" ,this.getRemarks());
        }
        if (this.getOperatorId() != null){
        lqw.eq(alias+"operator_id" ,this.getOperatorId());
        }
        if (StringUtils.isNotBlank(this.getOperatorName())){
        lqw.eq(alias+"operator_name" ,this.getOperatorName());
        }
        if (StringUtils.isNotBlank(this.getOperate())){
        lqw.eq(alias+"operate" ,this.getOperate());
        }
        if (StringUtils.isNotBlank(this.getCreateBy())){
        lqw.eq(alias+"create_by" ,this.getCreateBy());
        }
        if (this.getCreateTime() != null){
        lqw.eq(alias+"create_time" ,this.getCreateTime());
        }
        if (StringUtils.isNotBlank(this.getUpdateBy())){
        lqw.eq(alias+"update_by" ,this.getUpdateBy());
        }
        if (this.getUpdateTime() != null){
        lqw.eq(alias+"update_time" ,this.getUpdateTime());
        }
        if (this.getDelStatus() != null){
        lqw.eq(alias+"del_status" ,this.getDelStatus());
        }
        if (StringUtils.isNotBlank(this.getSearchName())) {
            lqw.and(wrapper -> wrapper.like("gp.sn", this.getSearchName()).or().like("gp.product_name", this.getSearchName()).or().like("gp.product_color", this.getSearchName()));
        }
        if (this.getSearchDate() != null) {
            lqw.apply("DATE_FORMAT(gp.create_time, '%Y-%m-%d') = '" + DateUtils.dateTime(this.getSearchDate()) + "'");
        }
    }
}
